package com.lt.lumentracks.controller.websocket;

import com.lt.lumentracks.entity.vo.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

// 用户在线状态查询接口
@RestController
@RequestMapping("/chat/user")
public class UserOnlineController {
    
    @Autowired
    private WebSocketServer_privateChat webSocketServer;
    
    @GetMapping("/online-status/{userId}")
    public Result<Map<String, Boolean>> getUserOnlineStatus(@PathVariable String userId) {
        Map<String, Boolean> result = new HashMap<>();
        result.put("online", webSocketServer.isUserOnline(userId));
        return Result.success(result);
    }
}